package com.example.mywifidirect;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.p2p.WifiP2pManager;
import android.net.wifi.p2p.WifiP2pManager.Channel;
import android.util.Log;

public class WiFiDirectBroadcastReceiver extends BroadcastReceiver {
	
	private WifiP2pManager mManager;
    private Channel mChannel;
    private MyWifiDirect mActivity;
	
    public WiFiDirectBroadcastReceiver(WifiP2pManager manager, Channel channel,
    		MyWifiDirect activity) {
        super();
        this.mManager = manager;
        this.mChannel = channel;
        this.mActivity = activity;
    }
    
	@Override
	public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub
		String action = intent.getAction();
		
		if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
            // Check to see if Wi-Fi is enabled and notify appropriate activity
			Log.i("truedano","Check to see if Wi-Fi is enabled and notify appropriate activity");
			
			int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
			if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
	            // Wifi Direct is enabled
				Log.i("truedano","Wifi Direct is enabled");
	        } else {
	            // Wi-Fi Direct is not enabled
	        	Log.i("truedano","Wi-Fi Direct is not enabled");
	        }
        } else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
            // Call WifiP2pManager.requestPeers() to get a list of current peers
        	Log.i("truedano","Call WifiP2pManager.requestPeers() to get a list of current peers");
        } else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
            // Respond to new connection or disconnections
        	Log.i("truedano","Respond to new connection or disconnections");
        } else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
            // Respond to this device's wifi state changing
        	Log.i("truedano","Respond to this device's wifi state changing");
        }
	}

}
